// pages/admin/putIn/recoveryRecord/recoveryRecord.js
const app = getApp();
import Api from '../../../../utils/http';
Page({

  /**
   * 页面的初始数据
   */
  data: {
    // dataList: [],
    datatext:[],
    maskStatus: false, //弹窗显示
    maskData: [{}], //点击显示到弹窗里面的数据
    animation: '', //弹窗出现的动画
    page:2,
    pageSize:9,
    code:null,
  },
  //关闭弹窗
  hideMask: function () {
    this.animation.top('-20%').opacity(0).step();
    this.setData({
      animation: this.animation.export(),
      maskStatus: false
    })

  },
  //显示弹窗
  showMask: function (e) {
    var that = this
    let id = e.currentTarget.dataset.index
    console.log(e.currentTarget.dataset.index)
    // var lid = datatext[index].id
    console.log(id)
    that.setData({
      maskStatus: true
    })
    that.animation.top('50%').opacity(1).step();
    that.setData({
      animation: that.animation.export()
    })
    that.getRecycleDetail(id);
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    var that=this;
    that.getRecycleList();
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {
    this.animation = wx.createAnimation()
  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {
    this.refreshData();
    wx.stopPullDownRefresh();
  },
  //回收记录数据下拉刷新
  refreshData: function () {
    var that = this;
    var uid=wx.getStorageSync('userid');
    var param = {
      uid: uid.id,//100
      pageNum: 1,
      pageSize: 9,
    };
    console.log(param)
    Api.ajax("/app/Zmanage/recycleList", param).then(res => {
      console.log(res)
      if (res.code == 200) {
        page++;
        that.setData({
          page:2,
          datatext:res.data,
          code:res.code
        })
        
      }
    });
  },
  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },
  //回收记录数据
  getRecycleList: function () {
    var that = this;
    var uid=wx.getStorageSync('userid');
    var page=that.data.page;
    var param = {
      uid: uid.id,//100
      pageNum: page,
      pageSize: 9,
    };
    console.log(param)
    Api.ajax("/app/Zmanage/recycleList", param).then(res => {
      console.log(res)
      if (res.code == 200) {
        page++;
        that.setData({
          datatext:res.data,
          code:res.code
        })
      }
    });
  },
  //详情
  getRecycleDetail:function(id){
    var that = this;
    console.log(that.data)
    var param = {
      type: 1,
      rid: id
    }
    console.log(param)
    Api.ajax("/app/Zmanage/recycleDetail", param).then(res => {
      console.log(res)
      if (res.code == 200) {
        that.setData({
          maskData: res.data,
        })
      }
    })
  },
  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})